<template>
	<view>
		<!-- <web-view :src="linkUrl"></web-view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				menuId:'',
				userId:'',
				linkUrl:''
			}
		},
		onLoad(options) {
			// console.log('options',options.url);
			// this.linkUrl = options.url?decodeURIComponent(options.url):''
			// this.menuId = options.id
			this.userId= this.getUrlParam('userId',location.href)
			this.menuId= this.getUrlParam('menuId',location.href)
			console.log('this.userId',this.userId);
			if(this.userId){
				this.handleLook()
			}
		},
		methods: {
			handleJump(appId) {
				this.$u.to(`/pages/index/openWeapp?appId=${appId}`)
			},
			handleLook(){
				this.$http.get('/api/home/scanAfter',{
					menuId:this.menuId,
					userId:this.userId
				}).then(res => {
					let result = res.data
					console.log('查看应用',result)
					if(result.type == 1) {
						location.href = result.url;
					}else {
						this.handleJump(result.url);
					}
					// this.linkUrl = result.url
				})
			},
			getUrlParam (name,httpCode) {
			  var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)') 
			   let url = httpCode
			   console.log(url);
			   if(url.includes('?')){
				   let urlParam = url.split('?')[1].split('#')[0].match(reg)
				   console.log(urlParam);
				   if (urlParam !== null) return unescape(urlParam[2])  
				   return null;
			   }
			}, 
		}
	}
</script>

<style>

</style>
